package com.fxz.controller;

import com.fxz.common.lang.Result;
import com.fxz.entity.SysUser;
import com.fxz.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fxz
 * @date 2021/5/10 8:41
 **/
@RestController
public class TestController {

    @Autowired
    SysUserService sysUserService;
    @Autowired
    BCryptPasswordEncoder bCryptPasswordEncoder;

    @GetMapping("/test")
    public Result test(){
        return Result.succ(sysUserService.list());
    }

    @GetMapping("/test/pass")
    public Result pass(){
        //加密后的密码
        String password = bCryptPasswordEncoder.encode("111111");
        System.out.println(password);
        //匹配
        boolean matches = bCryptPasswordEncoder.matches("111111", password);

        System.out.println("匹配结果:"+matches);

        return Result.succ(password);
    }

}
